package com.rockcent.job.task;

import com.rockcent.mall.lib.domain.enumclass.MerchantCouponStatus;
import com.rockcent.service.MerchantCouponSrv;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 卡券过期
 * Created by zhangjh on 2016/11/29.
 */
@Component
public class MerchantCouponTask {

    private final Logger log = LoggerFactory.getLogger(MerchantCouponTask.class);

    @Autowired
    private MerchantCouponSrv merchantCouponSrvImpl;

    @Scheduled(cron = "0 0/2 * * * *")
    public void soldout() {

        List<Long> ids = merchantCouponSrvImpl.findAllExpiredCouponIds();
        if (ids != null) {

//            log.info("======================>需要下架的卡卷数有：" + ids.size());
            merchantCouponSrvImpl.updateCoupoStatus(ids, MerchantCouponStatus.EXPIRED);


        }

    }

}
